import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import root,fsolve

## 使用scipy.optimize模块的root和fsolve函数进行数值求解方程

## 求解非线性方程组

def f3(i):
    x, y, z = i[0], i[1], i[2]
    return np.array([2*x**2+3*y-3*z**3-7
                    , x+4*y**2+8*z-10
                    , x-2*y**3-2*z**2+1
                ])

sol3_root = root(f3,[0,0,0])
sol3_fsolve = fsolve(f3,[0,0,0])

# f1=2*sol3_fsolve[0]**2+3*sol3_fsolve[1]-3*sol3_fsolve[2]**3-7
# f2=sol3_fsolve[0]+4*sol3_fsolve[1]**2+8*sol3_fsolve[2]-10
# print(f1)
# print(f2)

#print(sol3_root)  #输出过程
print(sol3_root.x)  #输出过程
print(sol3_fsolve)

